package com.atguigu.statisticsservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.statisticsservice.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author kaixuan
 * @since 2020-06-15
 */
@Api(description = "网站统计接口")
@RestController
@RequestMapping("/statisticsservice/daily")
//@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    /**
     * 根据日期获取统计数据
     * @param day
     * @return
     */
    @PostMapping("createDaily/{day}")
    public R createDaily(@PathVariable String day){
        dailyService.createStatistics(day);
        return R.ok();
    }

    /**
     * 创建图表
     * @param begin
     * @param end
     * @param type
     * @return
     */
    @GetMapping("showChart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin, @PathVariable String end, @PathVariable String type){
        Map<String,Object> map = dailyService.showChart(begin,end,type);
        return R.ok().data("map",map);
    }



}

